home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-11-25 | 1.8 KB | 67 lines | [TEXT/CCL2] |
-
- (in-package "VOICE-TOOLKIT")
-
-
- (defun mappend (fn lst)
- (apply #'append (mapcar fn lst)))
-
-
- (defun match-words-to-items (words)
- (if (null (rest words))
- (gethash (first words) *wordtable*)
- (intersection (gethash (first words) *wordtable*)
- (match-words-to-items (rest words)))))
-
-
- (defun guess-fixes ()
- (setf *fixes*
- (sort (mappend
- #'(lambda (word)
- (mapcar #'(lambda (fx)
- (list word fx))
- (match-words-to-items
- (remove word *wordlist*))))
- *wordlist*)
- #'compare-fix-weight)))
-
-
- (defun compare-fix-weight (f1 f2)
- "ordering function for sorting fixes"
- (> (fix-weight f1) (fix-weight f2)))
-
-
- (defun fix-weight (fix)
- (sum-fix-weight (get-twins (first fix))
- (set-diff (string-to-wordlist
- (text (second fix))) *wordlist*)))
-
-
- (defun sum-fix-weight (twins words &optional (count 0) (prob 0))
- (cond ((null twins)
- (if (< count 1) 0 (/ prob count)))
- ((member (twin-word (first twins)) words :test #'equal)
- (sum-fix-weight (rest twins)
- words
- (+ count (twin-count (first twins)))
- (+ prob (twin-prob (first twins)))))
- (t (sum-fix-weight (rest twins) words count prob))))
-
-
-
- (defun fix-word ()
- (first (first *fixes*)))
-
-
- (defun fix-item ()
- (second (first *fixes*)))
-
-
- (defun record-fix ()
- (let ((possible
- (set-diff (string-to-wordlist (text (fix-item)))
- *wordlist*)))
- (mapcar #'(lambda (word)
- (hash-twin (fix-word)
- (make-twin word 1 (/ 1 (length possible)))))
- possible)))
-